class Admin::ActualitiesController < Admin::BaseController
  # GET /actualities
  # GET /actualities.xml
  def index
    @actualities = Actuality.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @actualities }
    end
  end

  # GET /actualities/1
  # GET /actualities/1.xml
  def show
    @actuality = Actuality.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @actuality }
    end
  end

  # GET /actualities/new
  # GET /actualities/new.xml
  def new
    @actuality = Actuality.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @actuality }
    end
  end

  # GET /actualities/1/edit
  def edit
    @actuality = Actuality.find(params[:id])
  end

  # POST /actualities
  # POST /actualities.xml
  def create
    #add user_id
    params[:actuality]["user_id"] = session[:user_id]
    @actuality = Actuality.new(params[:actuality])

    respond_to do |format|
      if @actuality.save
        flash[:notice] = 'Actuality was successfully created.'
        format.html { redirect_to(:action => :show, :id => @actuality.id) }
        format.xml  { render :xml => @actuality, :status => :created, :location => @actuality }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @actuality.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /actualities/1
  # PUT /actualities/1.xml
  def update
    @actuality = Actuality.find(params[:id])

    respond_to do |format|
      if @actuality.update_attributes(params[:actuality])
        flash[:notice] = 'Actuality was successfully updated.'
        format.html { redirect_to(:action => :show, :id => @actuality.id) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @actuality.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /actualities/1
  # DELETE /actualities/1.xml
  def destroy
    @actuality = Actuality.find(params[:id])
    @actuality.destroy

    respond_to do |format|
      format.html { redirect_to(admin_actualities_url) }
      format.xml  { head :ok }
    end
  end
end
